/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"28C68DFB-615C-4FF5-A44C-1F11BC425C94"}
 */
function grabar(event) {
	databaseManager.saveData()
	databaseManager.setAutoSave(true)
	application.closeForm('ALTACC')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"54C7BC9D-25BC-4BD5-A728-A6C5F3E3EEEE"}
 */
function cancelar(event) {
	databaseManager.rollbackEditedRecords()
	databaseManager.setAutoSave(true)
	application.closeForm('ALTACC')
}

/**
 * Handle changed data.
 *
 * @param {Object} oldValue old value
 * @param {Object} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"919861D5-E4F2-4EAA-9644-E0DA4D54F206"}
 */
function onDataChangeOrden(oldValue, newValue, event) {
	elements.chk_ent_orden.enabled = orden
	return true
}

/**
 * Handle changed data.
 *
 * @param {Object} oldValue old value
 * @param {Object} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"C462DB4B-3D98-4B3A-A98E-0C0C0B4A26CF"}
 */
function onDataChangePagado(oldValue, newValue, event) {
	if (importe_pagado > importe)
	{
		globals.gDialog('Aviso','El importe es menor a lo que desea pagar','OK')
		return false
	}
	if (fecha_pago == null)
		fecha_pago = new Date()
	saldo_mov = importe - importe_pagado
	return true
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"CEEBBAB6-2CC3-459C-AF55-97ACBDBB4E5D"}
 */
function onShow(firstShow, event) {
	elements.chk_ent_orden.enabled = orden
}

/**
 * Handle changed data.
 *
 * @param {Object} oldValue old value
 * @param {Object} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"DADD5029-2443-44B3-AC93-C65B142519AA"}
 */
function onDataChangeImporte(oldValue, newValue, event) {
	saldo_mov = importe - importe_pagado
	return true
}
